package datastructure.book.tujiesuanfa.queueastack.bean;
/**
 * Your CQueue object will be instantiated and called as such:
 * CQueue obj = new CQueue();
 * obj.appendTail(value);
 * int param_2 = obj.deleteHead();
 */
public class CQueue {

    private int[] arr = new int[0];
    public CQueue() {

    }

    public void appendTail(int value) {
        if (arr == null || arr.length == 0) {
            arr = new int[]{value};
            return;
        }
        int[] tempArr = new int[arr.length+1];
        System.arraycopy(arr,0,tempArr,0,arr.length);
        tempArr[arr.length] = value;
        arr = tempArr;
    }

    public int deleteHead() {
        if (arr == null || arr.length == 0) {
            return -1;
        }
        int result = arr[0];
        int[] tempArr = new int[arr.length-1];
        System.arraycopy(arr,1,tempArr,0,tempArr.length);
        arr = tempArr;
        return result;
    }
}
